<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('新增Hadoop平台租户模型')" />
	<link rel="stylesheet" type="text/css" th:href="@{/ajax/libs/ace/ace.min.css}"/>
	<style>
		.tags {
			display: inline-block;
			padding: 4px 6px;
			color: #777;
			vertical-align: middle;
			background-color: #FFF;
			border: 1px solid #d5d5d5;
			width: 476px;
		}
	</style>
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-hadoopTenant-add">
			<input id="treeId" name="platformId" type="hidden" th:value="${hadoopPlatform.id}"   />
			<div class="form-group">	
				<label class="col-sm-3 control-label">租户名：</label>
				<div class="col-sm-8">
					<input id="tenant" name="tenant" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">租户组：</label>
				<div class="col-sm-8">
					<input id="tenantGroup" name="tenantGroup" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">所属Hadoop平台：</label>
				<div class="col-sm-8">
					<div class="input-group">
						<input class="form-control" type="text" id="treeName" name="platformName" readonly="true" th:value="${hadoopPlatform.name}">
						<span class="input-group-addon"><i class="fa fa-search"></i></span>
					</div>
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">是否为代理租户：</label>
				<div class="col-sm-8">
					<select id="isPoxyuser" name="isPoxyuser" class="form-control m-b" th:with="type=${@dict.getType('hadoop_proxy')}">
						<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
					</select>
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">Keytab文件路径：</label>
				<div class="col-sm-8">
					<input id="keytabFile" name="keytabFile" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">Yarn资源队列：</label>
				<div class="col-sm-8">
					<input type="text" id="yarnQueue" name="yarnQueue" class="form-control" placeholder="按回车键确定" />
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">是否启用：</label>
				<div class="col-sm-8">
					<div class="onoffswitch">
						<input type="checkbox" th:checked="true" class="onoffswitch-checkbox" id="isEnable" name="isEnable">
						<label class="onoffswitch-label" for="isEnable">
							<span class="onoffswitch-inner"></span>
							<span class="onoffswitch-switch"></span>
						</label>
					</div>
				</div>
			</div>
		</form>
	</div>
    <div th:include="include::footer"></div>
	<script type="text/javascript" th:src="@{/ajax/libs/ace/ace.min.js}"></script>
	<script type="text/javascript" th:src="@{/ajax/libs/ace/bootstrap-tag.min.js}"></script>
	<script type="text/javascript" th:src="@{/ajax/libs/ace/ace-elements.min.js}"></script>

    <script type="text/javascript">
		var prefix = ctx + "hadoop/hadoopTenant"
		$("#form-hadoopTenant-add").validate({
			rules:{
                tenant:{
					required:true,
                    rangelength: [3, 50]
				},
                tenantGroup:{
                    required:true,
                    rangelength: [3, 50]
				},
			},
			focusCleanup: true
		});

        var tag_input = $('#yarnQueue');
        try{
            tag_input.tag({
                    placeholder:tag_input.attr('placeholder')
			});
            // var $tag_obj = $('#form-field-tags').data('tag');
        }
        catch(e) {
            tag_input.after('<textarea id="'+tag_input.attr('id')+'" name="'+tag_input.attr('name')+'" rows="3">'+tag_input.val()+'</textarea>').remove();
        }

		function submitHandler() {
	        if ($.validate.form()) {
	            $.operate.save(prefix + "/add", $('#form-hadoopTenant-add').serialize());
	        }
	    }

        function doSubmit(index, layero){
            var body = layer.getChildFrame('body', index);
            $("#treeId").val(body.find('#treeId').val());
            $("#treeName").val(body.find('#treeName').val());
            layer.close(index);
        }
	</script>
</body>
</html>
